﻿// See https://aka.ms/new-console-template for more information

using Microsoft.International.Converters.PinYinConverter;
using Newtonsoft.Json;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using System.Data;
using WebHome_Admin;
using WebHome_Admin.Models;
using WebHome_API.Models;
using WebHome_API.Models.DBModels;


//Novel.CreateDataJson();
//Novel.CreateFileJson();
//Novel.AddDataJson();
//Novel.AddFileJson();

//Gal.CreateDataJson();
//Gal.CreateFileJson();
//Gal.GetInfo();
//Gal.AddNewJson();





//setPath();
//AddCode();


Console.WriteLine("Hello, World!");




static void setPath() { 
    using(MyContext context = new())
    {
        context.FilePaths.ToList().ForEach(item =>
        {
            item.Path = item.Path.Replace("\\Novel", "");
        });

        context.SaveChanges();
    }
}


//添加公告
static void AddNotice()
{
    var path = @"C:\Users\41280\Desktop\新建文本文档 (2).txt";
    using (StreamReader sr = File.OpenText(path))
    {
        while (sr.Peek() != -1)
        {
            //读取到的数据
            string a = sr.ReadToEnd().Replace("\n", "");
            Console.WriteLine(a);

            using (MyContext context = new MyContext())
            {
                context.Notice.Add(new Notice_Table()
                {
                    Title = "日常更新公告",
                    Text = a,
                    CreateTime = DateTime.Now,
                    IsDel = 0,
                    LastUpdateTime = DateTime.Now,
                });

                context.SaveChanges();
            }
        }
    }
}


//添加邀请码
static void AddCode(int count = 50)
{
    using (MyContext context = new())
    {
        for (int i = 0; i < count; i++)
        {
            context.Users.Add(new WebHome_API.Models.DBModels.User_Table()
            {
                Code = "sy_" + getGuid(),
                CreateTime = DateTime.Now,
                Gmail = "",
                GiveTime = new DateTime(2001, 06, 04),
                IsDel = 0,
                DelTime = new DateTime(2001, 06, 04),
                DelCause = "",
            });
        }
        context.SaveChanges();
    }
}

static string getGuid()
{
    long p = 1;
    foreach (byte b in Guid.NewGuid().ToByteArray())
    {
        p *= ((int)b + 1);
    }
    return string.Format("{0:x}", p - DateTime.Now.Ticks);
}



enum ChineseEnum
{
    未知 = 0,
    汉化 = 1,
    官方中文 = 2,
    生肉 = 3,
    AI = 4,
    部分汉化 = 5,
    机翻 = 6,
}

class DemoA
{
    public string Name { get; set; }
    public string Path { get; set; }
    public string Name2 { get; set; }

}

class Data
{
    public string Name { get; set; }
    public string NickName { get; set; }
    public string Club { get; set; }
    public string NickClub { get; set; }
    public string OldIndex { get; set; }
    public string NewIndex { get; set; }
    public string RootPath { get; set; }
    public string IsChinese { get; set; }
    public string Bug { get; set; }
    public string Url { get; set; }
    public string OldPwd { get; set; }
    public string ReleaseDate { get; set; }
}

